package common.lambda.function.demo;

import com.google.common.base.Function;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 苹果的筛选
 */
public class FilterApple {

    public static List<Apple> filterGreenApples(List<Apple> apples) {
        List<Apple> result = new ArrayList<>();
        for (Apple apple : apples) {
            if ("green".equals(apple.getColor()))
                result.add(apple);
        }

        Function<Apple, Boolean> appleBooleanFunction = (Apple a) -> a.getWeight() > 10;

        return result;
    }

    public static void main(String[] args) {
        List<Apple> apples = Arrays.asList(new Apple("green", 150),
                new Apple("yellow", 120),
                new Apple("green", 170));
        List<Apple> greenApples = filterGreenApples(apples);

        System.out.println(greenApples);
    }
}